Skip to content

fix(registration): display blocked username validation error in UI#39184

Open
sahillllllllll-bit wants to merge 2 commits intoRocketChat:developfrom
sahillllllllll-bit:fix/blocked-username-ui
Open

fix(registration): display blocked username validation error in UI#39184
sahillllllllll-bit wants to merge 2 commits intoRocketChat:developfrom
sahillllllllll-bit:fix/blocked-username-ui

Conversation

@sahillllllllll-bit
Copy link
Contributor

@sahillllllllll-bit sahillllllllll-bit commented Feb 28, 2026

Summary

This PR ensures that usernames blocked via Accounts_BlockedUsernameList are properly displayed as validation errors on the registration form.

Previously, when a blocked username (e.g., john.doe, sahil.dev) was submitted, the backend correctly returned error-blocked-username, but the UI did not render the error message. This resulted in no visible feedback for the user.

What was changed

  • Added explicit handling for error-blocked-username in the registration form.
  • The error is now displayed under the username field using the existing i18n translation (error-blocked-username).
  • Maintains consistency with other username validation errors (e.g., already exists, invalid format).

before :

UI did not render the Error message , but shown in dev tools Network

after changes:

Screenshot 2026-02-28 144001

Result

  • Blocked usernames now show a proper inline validation message.
  • No silent failures.
  • UI behavior is consistent with other validation cases.

Closes #39182

Summary by CodeRabbit

  • Bug Fixes
    • Registration now properly handles blocked usernames: the form displays a localized error message that includes the attempted username and stops further redundant error checks, preventing confusing or duplicate validation messages.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Feb 28, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Feb 28, 2026

⚠️ No Changeset found

Latest commit: 6fe5a41

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a0b8b2 and 6fe5a41.

📒 Files selected for processing (1)
  • packages/web-ui-registration/src/RegisterForm.tsx
📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • packages/web-ui-registration/src/RegisterForm.tsx
🧠 Learnings (2)
📚 Learning: 2026-01-17T01:51:47.764Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38219
File: packages/core-typings/src/cloud/Announcement.ts:5-6
Timestamp: 2026-01-17T01:51:47.764Z
Learning: In packages/core-typings/src/cloud/Announcement.ts, the AnnouncementSchema.createdBy field intentionally overrides IBannerSchema.createdBy (object with _id and optional username) with a string enum ['cloud', 'system'] to match existing runtime behavior. This is documented as technical debt with a FIXME comment at apps/meteor/app/cloud/server/functions/syncWorkspace/handleCommsSync.ts:53 and should not be flagged as an error until the runtime behavior is corrected.

Applied to files:

  • packages/web-ui-registration/src/RegisterForm.tsx
📚 Learning: 2026-02-24T19:36:55.089Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/page-objects/fragments/home-content.ts:60-82
Timestamp: 2026-02-24T19:36:55.089Z
Learning: In RocketChat/Rocket.Chat e2e tests (apps/meteor/tests/e2e/page-objects/fragments/home-content.ts), thread message preview listitems do not have aria-roledescription="message", so lastThreadMessagePreview locator cannot be scoped to messageListItems (which filters for aria-roledescription="message"). It should remain scoped to page.getByRole('listitem') or mainMessageList.getByRole('listitem').

Applied to files:

  • packages/web-ui-registration/src/RegisterForm.tsx
🔇 Additional comments (1)
packages/web-ui-registration/src/RegisterForm.tsx (1)

93-99: LGTM! Well-implemented error handling for blocked usernames.

The implementation correctly:

  • Checks both error.error and error.errorType using the same robust pattern as the error-invalid-email handler (line 90)
  • Uses early return to prevent cascading into unrelated error handlers
  • Includes the attempted username in the error message via getValues('username')
  • The i18n key error-blocked-username exists with the correct {{field}} parameter across all locale files

Walkthrough

Adds handling for the error-blocked-username error type in the registration form: when the server returns that error, the username field is set to a localized blocked-username validation message (including the attempted username) and further error checks are skipped.

Changes

Cohort / File(s) Summary
Blocked Username Error Handling
packages/web-ui-registration/src/RegisterForm.tsx
Adds a conditional branch for error-blocked-username that sets a field error on the username with a localized message containing the current username and returns early to stop further error processing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

type: bug, area: authentication

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and directly summarizes the main change: adding UI error display for blocked username validation.
Linked Issues check ✅ Passed The PR successfully implements the frontend fix objective from issue #39182 by handling error-blocked-username and displaying validation error on the username field.
Out of Scope Changes check ✅ Passed All changes are directly within scope of the linked issue #39182, focusing solely on frontend error handling and display for blocked usernames.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sahillllllllll-bit sahillllllllll-bit changed the title fix(registration): display blocked username validation error in UI (#39182) fix(registration): display blocked username validation error in UI Feb 28, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/web-ui-registration/src/RegisterForm.tsx">

<violation number="1" location="packages/web-ui-registration/src/RegisterForm.tsx:93">
P2: Blocked-username handling only checks error.errorType; backend errors can arrive in error.error as well (as shown by existing registration UI). This misses valid payloads and leaves the username error unreported.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Blocked usernames with special characters are not enforced and registration UI does not display error

1 participant